<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page isELIgnored="false" %>
<%
    String path = request.getContextPath();
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>李宁体育</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="<%=path%>/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="<%=path%>/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="<%=path%>/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="<%=path%>/css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link href="<%=path%>/css/plugins/chosen/chosen.css" rel="stylesheet">
    <link href="<%=path%>/css/plugins/ionRangeSlider/ion.rangeSlider.css" rel="stylesheet">
    <link href="<%=path%>/css/plugins/ionRangeSlider/ion.rangeSlider.skinFlat.css" rel="stylesheet">
    <link href="<%=path%>/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css"
          rel="stylesheet">
    <link href="<%=path%>/css/animate.min.css" rel="stylesheet">
    <link href="<%=path%>/css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link href="<%=path%>/umeditor/themes/default/css/umeditor.css" type="text/css" rel="stylesheet">
   
    <style type="text/css">
    	.te {
    		margin:0;
    		overflow:hidden;
    	}
    	.edui-modal {
    		position: absolute;
    		top: -270px;
    	}
    	.edui-tab-nav .edui-tab-item:last-child {
    		display:none;
    	}
    </style> 
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>修改当月精选商品</h5>                
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t" action="saveProductGroupon.do" method="post" id="productGrouponForm" enctype="multipart/form-data">
                        <div class="form-group">
                                    <input type="hidden" name="id" id="id" value="${productGroupon.id}"/>
                                    <input type="hidden" name="oneImg" id="oneImg" />  
                                    <input type="hidden" name="twoImg" id="twoImg" />   
									<label class="col-sm-2 control-label">商品名称</label><font color="red">*</font>
									<div class="col-sm-3">
										<input type="text" class="form-control" name="name" id="name" value="${productGroupon.name}" maxlength="64" placeholder="商品名称"></input>
									</div>
									</div>
									<div class="form-group">
										<label class="col-sm-2 control-label">SKU编码</label><font id="errSku" color="red">*</font>
										<div class="col-sm-3">
											<input type="text" class="form-control" name="sku" id="sku" maxlength="12" value="${productGroupon.sku}"  placeholder="SKU编码" readonly="readonly"  style='border-left:0px;border-top:0px;border-right:0px;border-bottom:1px'></input>
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-2 control-label">吊牌价</label>
										<div class="col-sm-3">
											<input type="text" class="form-control" name="originPrice" id="originPrice" value="${productGroupon.originPrice}" placeholder="吊牌价"></input>
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-2 control-label">团购/精选价</label>
										<div class="col-sm-3">
											<input type="text" class="form-control" name="salePrice" id="salePrice" value="${productGroupon.salePrice}"  placeholder="团购/精选价"></input>
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-2 control-label">上下架</label><font color="red">*</font>
										<div class="col-sm-3">
										   <select class="form-control m-b" name="saleStatus" id="saleStatus">
												<option value="">请选择类型</option>
												<option value="1" <c:if test="${productGroupon.saleStatus eq '1'}">selected="selected"</c:if>>上架</option>
												<option value="0" <c:if test="${productGroupon.saleStatus eq '0'}">selected="selected"</c:if>>下架</option>
											</select>
										</div>
									</div>									
									<div class="form-group">
										<label class="col-sm-2 control-label">分类</label><font color="red">*</font>
										<div class="col-sm-3">
										  <select class="form-control m-b" name="categoryId" id="categoryId">
											<c:forEach items="${categoryProduct}" var="mp">
                                               <option value="${mp.id}" <c:if test="${productGroupon.categoryId == mp.id}">selected="selected"</c:if>>${mp.name}</option>
                                            </c:forEach>
                                          </select>
										</div>
									</div>								
									<div class="form-group">
										<label class="col-sm-2 control-label">是否爆款/热卖/新品</label><font color="red">*</font>
										<div class="col-sm-3">							
											<input  name="tagInfo"  type="radio" value="1"  <c:if test="${productGroupon.tagInfo == '1'}">checked</c:if>/>&nbsp;爆款&nbsp;&nbsp;&nbsp;
                                            <input  name="tagInfo"  type="radio" value="2"  <c:if test="${productGroupon.tagInfo == '2'}">checked</c:if>/>&nbsp;热卖&nbsp;&nbsp;&nbsp;
                                            <input  name="tagInfo"  type="radio" value="3"  <c:if test="${productGroupon.tagInfo == '3'}">checked</c:if>/>&nbsp;新品
										</div>							
									</div>	
									<div class="form-group">
										<label class="col-sm-2 control-label">库存</label><font color="red">*</font>
										<div class="col-sm-3">
											<input type="text" class="form-control" id="stockQty" name="stockQty" value="${productGroupon.stockQty}" placeholder="库存"></input>
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-2 control-label">是否优选</label><font color="red">*</font>
										<div class="col-sm-3">
										   <select class="form-control m-b" name="isHot" id="isHot">
												<option value="0" <c:if test="${productGroupon.isHot eq '0'}">selected="selected"</c:if>>是</option>
												<option value="1" <c:if test="${productGroupon.isHot eq '1'}">selected="selected"</c:if>>否</option>
											</select>
										</div>
									</div>								
									<div class="form-group">
										<label class="col-sm-2 control-label">排序</label><font color="red">*</font>
										<div class="col-sm-3">
											<input type="text" class="form-control" id="sort" name="sort" value="${productGroupon.sort}" placeholder="排序"></input>
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-2 control-label">O2O配置</label>
										<div class="col-sm-3">
											<input type="text" class="form-control" id="o2o" name="o2o" value="${productGroupon.o2o}" placeholder="O2O配置"></input>
										</div>
									</div>	
									<div class="form-group">
										<label class="col-sm-2 control-label">Banner图</label><font color="red">*</font>
										<div class="col-sm-3">
											<input id="picture" name="picture" type="file"  title="商品大图" placeholder="商品大图" onchange="validateImg();"/> 
										    <span id="imgHint" style="color:red">图片比例1:1,建议尺寸750x750px,大小不能超过1M</span>
										    <!-- </br>
										    <span id="imgsize" style="color:red"></span> -->
										</div>
									</div>								
									<div class="form-group">
										<label class="col-sm-2 control-label">商品图片</label><font color="red">*</font>
										<div class="col-sm-3">
											<input id="pictureTwo" name="picture"  type="file"  title="图片" placeholder="图片" onchange="validateImg();"/> 
										    <span id="imgHint" style="color:red">图片比例1:1,建议尺寸750x750px,大小不能超过1M</span>
										    <!-- </br>
										    <span id="imgsizeTwo" style="color:red"></span> -->
										</div>
									</div>	
									<div class="form-group">
										<label class="col-sm-2 control-label">商品详情</label>
										<div class="col-sm-8">
										    <script type="text/plain" id="details" name="details" style="width:100%; height:150px">${productGroupon.details}</script>																						
										</div>
									</div>																									
									<div class="form-group">
                                         <div class="col-sm-4 col-sm-offset-3">
                                          <button class="btn btn-primary" type="submit" onclick="editor.post();">保 存</button>
                                          &nbsp;<button class="btn btn-info" type="button" onclick="goBackProduct()">返  回</button>
                                         </div>
                                    </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="<%=path%>/js/jquery.min.js?v=2.1.4"></script>
<script src="<%=path%>/js/bootstrapValidator.min.js"></script>
<!--下拉框-->
<script src="<%=path%>/js/plugins/chosen/chosen.jquery.js"></script>

<script src="<%=path%>/umeditor/third-party/template.min.js"></script>
<script src="<%=path%>/umeditor/umeditor.config.js"></script>
<script src="<%=path%>/umeditor/umeditor.min.js" type="text/javascript" charset="utf-8"></script>
<script src="<%=path%>/umeditor/lang/zh-cn/zh-cn.js"></script>
<script>
var um = UM.getEditor('details', {
	fullscreen : false,
	toolbar:[
        'source | undo redo | bold italic underline strikethrough | superscript subscript | forecolor backcolor | removeformat |',
        'insertorderedlist insertunorderedlist | selectall cleardoc paragraph | fontfamily fontsize' ,
        '| justifyleft justifycenter justifyright justifyjustify |',
        'link unlink | emotion image video  | map',
        '| horizontal print preview'
    ]
});
//um.setDisabled();
function validateImg(){
	   var maxsize = 1*1024*1024;  //1M 
	   var img = $("#picture").val().toLowerCase().split('.');
	   var imgT = $("#pictureTwo").val().toLowerCase().split('.');
	   
	   var obj_file = document.getElementById("picture");  
	   var obj_file_two = document.getElementById("pictureTwo");  
	   if(img == ''){   
	   }else{
		   if (img[img.length - 1] == 'gif' || img[img.length - 1] == 'jpg'|| img[img.length - 1] == 'jpeg'|| img[img.length - 1] == 'png') {			   
			   var filesize = 0;  
               filesize = obj_file.files[0].size
               if(filesize>maxsize){
            	   /* errMsg = "上传的图片文件不能超过1M！";
            	   $("#imgsize").html(errMsg) */
            	   $("#picture").val("");
                   return false;  
               }else{
            	   //$("#imgsize").remove();
            	   $("#oneImg").val("1");
               }
		   }else{			   
			   $("#picture").val("");
			   return false;
		   }  
	   }
	   if(imgT == ''){   
	   }else{
		   if (imgT[imgT.length - 1] == 'gif' || imgT[imgT.length - 1] == 'jpg'|| imgT[imgT.length - 1] == 'jpeg'|| imgT[imgT.length - 1] == 'png') {			   
			   var filesizetwo = 0;  
			   filesizetwo = obj_file_two.files[0].size
               if(filesizetwo>maxsize){
            	   /* errMsg = "上传的图片文件不能超过1M！";
            	   $("#imgsizeTwo").html(errMsg) */
            	   $("#pictureTwo").val("");
                   return false;  
               }else{
            	   //$("#imgsizeTwo").remove();
            	   $("#twoImg").val("1");
               }
		   }else{			  
			   $("#pictureTwo").val("");
			   return false;
		   }  
	   }
 }
<%-- function checkSKU(){
	 var sku = $("#sku").val();
	 if(sku==null || sku==''){     		
	 }else{
		$.ajax({
	        url: "<%=path%>/productInfo/toCheckProductGrouponSku",
	        type: "post",
	        data: {"sku": sku,"type":2},
	        dataType: "json",
	        success: function (data) {   	              
	              if(data.status=='400'){ 
	            	 $("#errSku").html(data.msg); 
	            	 $("#sku").val("");    	       
	              }  	              
	        },
	        error: function () {
	            alert("异常，请稍后重试");
	        }
	  });
	 }        
} --%>
    function goBackProduct() {
        window.location.href="<%=path%>/productInfo/queryProductInfoList";
	}
    //表单验证
    var config = {
            ".chosen-select": {},
            ".chosen-select-deselect": {allow_single_deselect: !0},
            ".chosen-select-no-single": {disable_search_threshold: 10},
            ".chosen-select-no-results": {no_results_text: "Oops, nothing found!"},
            ".chosen-select-width": {width: "95%"}
    }; 
    
    for (var selector in config)$(selector).chosen(config[selector]);
    $(document).ready(function () {
        $('#productGrouponForm').bootstrapValidator({
            message: 'This value is not valid',
            fields: {
                name: {
                    message: '商品名称不能为空！',
                    validators: {
                        notEmpty: {
                            message: '商品名称不能为空！'
                        }
                    }
                },
                sku: {
                    message: 'SKU编码不能为空！',
                    validators: {
                        notEmpty: {
                            message: 'SKU编码不能为空！'
                        }
                    }
                },
                stockQty: {
                    message: '库存不能为空！',
                    validators: {
                        notEmpty: {
                            message: '库存不能为空！'
                        }
                    }
                },
                sort: {
                    message: '排序不能为空！',
                    validators: {
                        notEmpty: {
                            message: '排序不能为空！'
                        }
                    }
                },
                /* picture: {
                	message: '图片不能为空！',
                    validators: {
                        notEmpty: {
                            message: '图片不能为空！'
                        }

                    }
                }, */
            },
            submitHandler: function(validator, form, submitButton) {
            }
        });
    });
</script>
</body>
</html>
